package leetcode2;
import java.util.*;
public class Day18 {

    //寻找重复数
    public int findDuplicate(int[] nums) {
        Arrays.sort(nums);
        for(int i=0;i<nums.length;i++) {
            if(i<nums.length && nums[i] == nums[i+1]) return nums[i];
        }
        return -1;
    }

    //反转字符串
    public void reverseString(char[] s) {
        int left=0,right=s.length-1;

        while(left < right) {
            char ch = s[left];
            s[left++] = s[right];
            s[right--] = ch;
        }
    }
}
